<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE HTML>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<base href="<%=basePath%>">
<html lang="zn-cn">
<head>
    <meta charset="UTF-8">
    <meta name="format-detection" content="telephone=no"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <title>组织介绍</title>
    <link rel="stylesheet" href="css/service.css">
    <script type="text/javascript" src="js/jquery.min.js"></script>
    <script type="text/javascript" src="js/base.js"></script>
    <script type="text/javascript" src="js/common.js"></script>
    <script type="text/javascript" src="js/handle.js"></script>
    <script type="text/javascript">

        var carTypeArray = ['<div class="frame_0">框架</div>','<div class="frame_1">1</div>', '<div class="frame_2">2</div>'];
        var unBindCardNo = null;
        var unbindText = "<div class='unbind_layer' style='display:none'><div class='unbind_box'><img src='img/unbind_top.jpg'><p><span class='unbind_certain'>解绑赣通卡</span><span class='unbind_cancel'>取消</span></p></div></div>";
        var norecordText = "<div class='norecord'><img src='img/nobindcard.png'><p>你没有加入任何组织哦!</p></div>";

        // 获取卡列表
        function getCardList() {
            console.log('step into getCardList()')
            var data = {
                cardType: 0
            }
            console.log(data)
            $(".loading").show();
            $.ajax({
                url: $.httpRootPath()+'rest/group/getGroupList',
                type: 'GET',
                dataType: 'json',
                data: data,
                cache: false,
                timeout: 15000,
                success: function (r) {
                    console.log(r);
                    $(".loading").hide();
                    if (r.code != "00" && r.code != "01") {
                        errorToast(r.msg, 3);
                    }
                    if (r.data.length == 0) {
                        $(".norecordbox").append(norecordText);
                        return false;
                    }

                    $("body").append(unbindText);

                    for (var i = 0; i < r.data.length; i++) {

                        var modCal = 0;
                        var obj = r.data[i],
                            cardNo = obj.id,
                            cardNoFormat = obj.name,
                            vehiclePlate = obj.createTime;
                        cardType = carTypeArray[obj.type];
                        var innerText = "<div class='carditem' data-cardNo=" +
                            cardNo + "><div class='itemtop_out card_bg" +
                            modCal + "'><div class='itemtop'><h2>" + cardNoFormat
                            + "</h2><h3>" + vehiclePlate
                            + "</h3></div></div><div class='itembtn'>组织详情<span><img	src='img/right_arr3.png'></span></div></div>";

                        $(".cardlist_box").append(innerText);

                    }
                },
                error: function (e) {
                    console.log(e);
                    $(".loading").hide();
                    $(".norecordbox").append(norecordText);
                    ajaxErrorEvent(e);

                }
            });
        }


        $(function () {

            // 获取卡列表的入口
            getCardList();

            $(".cardlist_box").on('click', '.itembtn', function (event) {
                var targetCardNo = $(this).parents(".carditem").attr('data-cardNo');
                window.location.href = "wxmp/info/group?oid=" + targetCardNo;
            });

        })
    </script>

</head>
<body class="ed">
<div class="wrap por outwrap">

    <div class="wrapper3 height_auto">

        <div class="norecordbox"></div>
        <div class="cardlist_box"></div>
        <div class="bottomLogo">
            <%--<p>本服务由 @好好de浩浩 提供</p>--%>
            <%--<p>联系电话：17090077783</p>--%>
        </div>
    </div>
</div>
<div class="toast toast_timeout" style="display:none">网络异常，请稍后重试！</div>
<div class="toast toast_error" style="display:none"></div>
<div class="loading" style="display:none">
    <img src="img/loading.gif"></div>
</body>
</html>